#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <string>

using namespace std;

class Solution
{
public:
    string addBinary(string a, string b)
    {
        int la = a.size() - 1;
        int lb = b.size() - 1;
        int tmp = 0;
        string ret;
        while (la >= 0 || lb >= 0 || tmp == 1)
        {
            if (la >= 0) tmp += a[la--] - '0';
            if (lb >= 0) tmp += b[lb--] - '0';
            ret += to_string(tmp % 2);
            tmp /= 2;
        }
        reverse(ret.begin(), ret.end());
        return ret;
    }
};

int main()
{
    Solution s;
    string str1 = "1111";
    string str2 = "1010";

    cout << s.addBinary(str1, str2);
    return 0;
}